package jalgebrava.util;

public final class Pair<A,B> {
	public final A a;
	public final B b;
	private Pair(A inA, B inB) {
		this.a = inA;
		this.b = inB;
	}
	public static <A,B> Pair<A,B> pair(A a, B b) {
		return new Pair<A,B>(a,b);
	}
	
	@Override
	public boolean equals(Object obj) {
		if (obj == null || !(obj instanceof Pair)) {
			return false;
		}
		Pair<?,?> other = (Pair<?,?>) obj;
		return equals(other);
	}
	public boolean equals(Pair<?,?> other) {
		return a.equals(other.a) && b.equals(other.b);
	}
	@Override
	public int hashCode() {
		return a.hashCode() * 31 + b.hashCode();
	}
	@Override
	public String toString() {
		return "("+a.toString()+","+b.toString()+")";
	}
	
}
